<!doctype html>
<html><!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>添加供应商</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/gbRst.js"></script>
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script>
<link href="../css/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/city.js"></script>
<script type="text/javascript" src="../js/operateType.js"></script>
<script type="text/javascript" src="../js/industryType.js"></script>
<script type="text/javascript" src="../js/shopType.js"></script>
<script type="text/javascript" src="../js/doubleDate2.0.js"></script> 

<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<style type="text/css">
#window_change p label span img{
    border: 1px solid #CCCCCC;
    height: 51px;
    vertical-align: middle;
    width: 75px;

}

</style>
<script type="text/javascript" >
var shopId="shopId";
var editor;
var indexStr;
$(function(){
	getProvince("provinceList");
	getIndustry("IndustryList")
	addMargin($("#window3"));
	addMargin($("#window4"));
	addMargin($("#window5"));
	addMargin($("#window6"));
	retForm();
	$('.doubledate').kuiDate({
		className:'doubledate',
		isDisabled: "0"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});

})

function chooseProvince(id,pName){
	if(provinceId!=id){		
	$("#provinceName").val(pName);
	provinceId=id;
	$("#cityName").val("");
	cityId=null;
	}
	$("#yinying").hide();
	$("#window1").hide();
}
function chooseCity(id,name){
	
	cityId=id;
	$("#cityName").val(name);
	$("#yinying").hide();
	$("#window2").hide();

}
function showCityList(){
	if(IsEmpty(provinceId)){
		art.dialog({fixed:true, lock: true,content:"请先选择省份",icon:'error',ok:true});	
		return false;
	}
	getCity("cityList")
	showHideDiv('window2');
	addMargin($("#window2"))
}
function chooseOperateLargeType(id,name){
	if(operateLargeTypeId!=id){		
		$("#operateLargeTypeName").val(name);
		operateLargeTypeId=id;
		$("#operateTypeName").val("");
		operateTypeId=null;
		}
		$("#yinying").hide();
		$("#window5").hide();
}
function showOperateType(){
	if(IsEmpty(operateLargeTypeId)){
		art.dialog({fixed:true, lock: true,content:"请先选择经营大类",icon:'error',ok:true});	
		return false;
	}
	 getOperateType("operateTypeList");
	 addMargin($("#window6"))
	 showHideDiv('window6');
}
function chooseOperateType(id,name){
	
	operateTypeId=id;
	$("#operateTypeName").val(name);
	$("#yinying").hide();
	$("#window6").hide();

}

function save(){
		addInfo();
}

function addInfo(){
	var name=$("#name").val().replace(/\s/gi,'');
	if(IsEmpty(name)){
		art.dialog({fixed:true, lock: true,content:"供应商名称不能为空",icon:'error',ok:true});	
		$("#name").focus();
		return false
	}else{
		if(name.length>50){
			art.dialog({fixed:true, lock: true,content:"供应商名称过长(50字以内)",icon:'error',ok:true});	
			$("#name").focus();
			return false	
		}
	}
	var code=$("#code").val().replace(/\s/gi,'');
	if(IsEmpty(code)){
		art.dialog({fixed:true, lock: true,content:"供应商编码不能为空",icon:'error',ok:true});	
		$("#code").focus();
		return false
	}else{
		if(code.length>20){
			art.dialog({fixed:true, lock: true,content:"供应商编码过长(20字以内)",icon:'error',ok:true});	
			$("#code").focus();
			return false	
		}
	}
	var fax=$("#fax").val().replace(/\s/gi,'');

	var tel=$("#tel").val().replace(/\s/gi,'');
	var mp=$("#mp").val().replace(/\s/gi,'');
		if(IsNotEmpty(mp)){
		   var reg=	/^(13|15|18)[0-9]{9}$/;
		   if(!reg.test(mp)){
				art.dialog({fixed:true, lock: true,content:"手机格式错误",icon:'error',ok:true});	
				$("#mp").focus();
				return false;
		   }
		}
	var email=$("#email").val().replace(/\s/gi,'');
	if(IsNotEmpty(email)){
	   var reg=	/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	   if(!reg.test(email)){
			art.dialog({fixed:true, lock: true,content:"邮箱格式错误",icon:'error',ok:true});	
			$("#email").focus();
			return false;
	   }
	}
	
	
	
	var regNo=$("#regNo").val().replace(/\s/gi,'');
	if(IsEmpty(regNo)){
		art.dialog({fixed:true, lock: true,content:"工商号不能为空",icon:'error',ok:true});	
		$("#regNo").focus();
		return false;
	}else{
		if(regNo.length>20){
			art.dialog({fixed:true, lock: true,content:"工商号过长(20字以内)",icon:'error',ok:true});	
			$("#regNo").focus();
			return false;	
		}
	}
	
	var legal=$("#legal").val().replace(/\s/gi,'');
	var status=$("#status").val().replace(/\s/gi,'');
	var major=$("#major").val().replace(/\s/gi,'');
	if(IsNotEmpty(major)){
		if(major.length>4000){
			art.dialog({fixed:true, lock: true,content:"经营范围过长(4000字以内)",icon:'error',ok:true});	
			$("#major").focus();
			return false;	
		}
	}
	var memo=$("#memo").val().replace(/\s/gi,'');
	if(IsNotEmpty(memo)){
		if(memo.length>255){
			art.dialog({fixed:true, lock: true,content:"备注过长(256字以内)",icon:'error',ok:true});	
			$("#memo").focus();
			return false;	
		}
	}

	if(IsEmpty(industryId)){
		art.dialog({fixed:true, lock: true,content:"请选择行业类型",icon:'error',ok:true});	
		$("#industryName").val("");
		return false;
	}
	if(IsEmpty(cityId)){
		art.dialog({fixed:true, lock: true,content:"请选择所在城市",icon:'error',ok:true});	
		$("#shopName").val("");
		return false;
	}
	var address=$("#address").val().replace(/\s/gi,'');
	if(IsEmpty(address)){
		art.dialog({fixed:true, lock: true,content:"地址不能为空",icon:'error',ok:true});	
		$("#address").focus();
		return false;
	}
	var website=$("#website").val().replace(/\s/gi,'')
	var zipCode=$("#zipCode").val().replace(/\s/gi,'')
	var contactMan=$("#contactMan").val().replace(/\s/gi,'')
	var openTime=$("#openTime").val().replace(/\s/gi,'')
	var openBank=$("#openBank").val().replace(/\s/gi,'')
	var bankAccount=$("#bankAccount").val().replace(/\s/gi,'')
	var heads=null;
	var datas=null;
	if(IsEmpty(openTime)){
	 heads=new Array("indusTypeId","website","zipCode","mp","code","name","contactMan","tel","fax","email","address","status","regNo","legal","major","cityId","memo","openBank","bankAccount");
	 datas=new Array(industryId,website,zipCode,mp,code,name,contactMan,tel,fax,email,address,status,regNo,legal,major,cityId,memo,openBank,bankAccount);
	}else{
		 heads=new Array("indusTypeId","website","zipCode","mp","code","name","contactMan","tel","fax","email","address","status","regNo","legal","major","openTime","cityId","memo","openBank","bankAccount");
		 datas=new Array(industryId,website,zipCode,mp,code,name,contactMan,tel,fax,email,address,status,regNo,legal,major,openTime,cityId,memo,openBank,bankAccount);
			
	}
	var parser = new Object();
	var jsonParserStr = null;
	if (IsNotEmpty(datas)){
		addToParser(heads, datas, "add" , parser);
		jsonParserStr =  JSON.stringify(parser);
	}
	$("#close_this").attr("disabled",true)
	$.post("../supplier/insert/insertInfo",{"data":jsonParserStr}, function(data) {
		$("#close_this").attr("disabled",false)
		var dt = JSON.parse(data);
		if(IsEmpty(dt)){
			art.dialog({fixed:true, lock: true,content:dt.msg,icon:'error',ok:true});	
			return false;
			}
			if(dt.state==0){
				retForm();
				art.dialog({fixed:true, lock: true,content:"添加成功",icon:'succeed',ok:true});	
			}else if(dt.state==1){
				art.dialog({fixed:true, lock: true,content:dt.msg,icon:'error',ok:true});	
			}else{
				checkStateShowErrorMsgAndDealResult(data);
			}
		
	});
	
}

function chooseloadIndustryTable(iId,iName){
	industryId=iId
	$("#industryName").val(iName);
	$("#yinying").hide();
	$("#window3").hide();
}
function chooseShopType(ctId,ctName){
	shopTypeId=ctId;
	$("#shopTypeName").val(ctName);
	$("#yinying").hide();
	$("#window4").hide();
}

function retForm(){
	$("#code").val("");
	$("#name").val("");
	$("#mp").val("");
	$("#fax").val("");
	$("#tel").val("");
	$("#email").val("");
	$("#provinceName").val("");
	$("#cityName").val("");
	$("#zipCode").val("");
	$("#regNo").val("");
	$("#legal").val("");
	$("#major").html("");
	$("#contactMan").val("")
	$("#openBank").val("")
	$("#industryName").val("")
	$("#website").val("");
	$("#doflag").val(1);
	$("#addr").val("");
	$("#memo").val("");
	$("#major").val("");
	$("#bankAccount").val("");
	$("#openTime").val("");
	$("#address").val("");
	$("#close_this").attr("disabled",false)
	indexStr=null;
	provinceId=null;
	provinceName=null;
	cityId=null;
	cityName=null;
	shopTypeId=null;
	shopTypeName=null;
	industryId=null;
	industryName=null;
	operateLargeTypeId=null;
	operateLargeTypeName=null;
	operateTypeId=null;
	operateTypeName=null;

}


function returnURl(){
	window.location.href='setSupplier.html?flag=1'
}	
</script>
</head>

<body>
<div id="yinying1"></div>
<div id="yinying"></div>
<div id="window_changeff" class="hideDiv setHTML" >
	<textarea id="editIndex" name="editIndex"></textarea>
	<div class="BottomBtn">
        <input type="button"  value="确定" class="common_btn" onclick="saveHtml()" >
        <input type="button" value="取消" class="common_btn" style="background-color: red;" onclick="cancelHtml()" >
      </div>
</div>
<div id="shopShow" class="hideDiv">
    <div style="float:right;margin-bottom:5px;width:20px;height:20px;line-height:20px;text-align:center;background-color:#eee;margin-bottom:5px;border:1px solid #ccc;" > <span style="cursor: pointer;font-size: 14px;" onclick="closeShopShow();" >X</span> </div>
    <div class="bottom_search"><input type="text" id="searchName"><input type="button" style="width:auto;margin-left:5px;" value="查询" onclick="search2()"></div>
    <table   id="shopList" cellpadding="4" cellspacing="0" border="1" width="100%">
    <thead>
    <tr>
    <th>店面ID</th>
    <th>店面名称</th>
    <th>电话</th>
    <th>操作</th>
    </tr>
    </thead>
    </table>
    	<div id="shopPager"></div>
    </div>
<!-- InstanceBeginEditable name="EditRegion3" -->
<script type="text/javascript" src="../js/jquery.cityselect.js"></script>
<script type="text/javascript">
$(function(){
	$(".hideDiv").each(function(){
		addMargin($(this));
	})
	
});
</script>
<!-- 省（市）-->
<div class="hideDiv hideOver" id="window1">
 <div class="closeTop"><span class="closeThe" onclick="closeParent($(this))"><img src="../images/close.png"></span></div>
	<table id="provinceList" width="100%" cellspacing="1" cellpadding="0" border="0" class="member_list">
    	    	<caption>省份选择   </caption>
    	<thead>
    	<tr>
        	<th>省份</th>
        	<th>操作</th>
        	<th>省份</th>
        	<th>操作</th>
        	<th>省份</th>
        	<th>操作</th>
        	<th>省份</th>
        	<th>操作</th>
        </tr>
        </thead>
        <tbody>
        	
        </tbody>
    </table>
</div>
<!-- 城市（区）-->
<div class="hideDiv hideOver" id="window2">
 <div class="closeTop"><span class="closeThe" onclick="closeParent($(this))"><img src="../images/close.png"></span></div>
	<table id="cityList" width="100%" cellspacing="1" cellpadding="0" border="0" class="member_list">
    	<caption>城市选择   </caption>
    	<thead>
    	<tr>
        	<th>城市</th>
        	<th>操作</th>
        	<th>城市</th>
        	<th>操作</th>
        	<th>城市</th>
        	<th>操作</th>
        	<th>城市</th>
        	<th>操作</th>
        </tr>
        </thead>
        <tbody>
        	
        </tbody>
    </table>
</div>
<!-- 行业类型 -->
<div class="hideDiv hideOver" id="window3">
 <div class="closeTop"><span class="closeThe" onclick="closeParent($(this))"><img src="../images/close.png"></span></div>
	<table id="IndustryList" width="100%" cellspacing="1" cellpadding="0" border="0" class="member_list">
    	<caption>行业类型       </caption>
    	<thead>
    	<tr>
        	<th>行业类型</th>
        	<th>操作</th>
        </tr>
        </thead>
        <tbody>
        	
        </tbody>
    </table>
    <div id="indusPager" class="shopPager"></div>
</div>
<!-- 店面类型 -->
<div class="hideDiv hideOver" id="window4">
 <div class="closeTop"><span class="closeThe" onclick="closeParent($(this))"><img src="../images/close.png"></span></div>
	<table id="shopTypeList" width="100%" cellspacing="1" cellpadding="0" border="0" class="member_list">
    	<caption>店面类型      </caption>
    	<thead>
    	<tr>
        	<th>店面类型</th>
        	<th>操作</th>
        </tr>
        </thead>
        <tbody>
        
        </tbody>
    </table>
</div>
<!-- 经营大类 -->
<div class="hideDiv hideOver" id="window5">
 <div class="closeTop"><span class="closeThe" onclick="closeParent($(this))"><img src="../images/close.png"></span></div>
	<table id="operateLargeList" width="100%" cellspacing="1" cellpadding="0" border="0" class="member_list">
    	<caption>经营大类       </caption>
    	<thead>
    	<tr>
        	<th>类别</th>
        	<th>操作</th>
        	<th>类别</th>
        	<th>操作</th>
        	<th>类别</th>
        	<th>操作</th>
        	<th>类别</th>
        	<th>操作</th>
        </tr>
        </thead>
        <tbody>
        	
        </tbody>
    </table>
</div>
<!-- 经营小类 -->
<div class="hideDiv hideOver" id="window6">
 <div class="closeTop"><span class="closeThe" onclick="closeParent($(this))"><img src="../images/close.png"></span></div>
	<table id="operateTypeList" width="100%" cellspacing="1" cellpadding="0" border="0" class="member_list">
    	<caption>经营小类         </caption>
    	<thead>
    	<tr>
        	<th>类别</th>
        	<th>操作</th>
        	<th>类别</th>
        	<th>操作</th>
        	<th>类别</th>
        	<th>操作</th>
        	<th>类别</th>
        	<th>操作</th>
        </tr>
        </thead>
        <tbody>
        	
        </tbody>
    </table>
</div>
<div class="container" id="container">
  <div class="container_R fr">
	<div class="place"><a href="javaScript:void(0);" onclick='returnURl()' >供应商设置</a><span> &gt; <span>添加供应商<a class="goHome"  href="javaScript:void(0);" onclick='returnURl()'>返回</a></div>
    <div id="window_change" class="member_search">
	<p style="white-space: nowrap;">
      <label><span>供货商编码：</span>
        <input type="text" id="code">
      </label>
      <label><span>供货商名称：</span>
        <input type="text" id="name">
      </label>
       <label><span>手机：</span>
        <input type="text" id="mp">
      </label>
    </p>
    <p>
      <label><span>传真：</span>
        <input type="text" id="fax">
      </label>
      <label><span>电话：</span>
        <input type="text" id="tel">
      </label>
      <label><span>邮箱：</span>
        <input type="text" id="email">
      </label>
    </p>
    <p>
      <label><span>邮编：</span>
        <input type="text" id="zipCode">
      </label>
      <label><span>网址：</span>
        <input type="text" id="website">
      </label>
      <label><span>联系人：</span>
        <input type="text" id="contactMan">
      </label>
    </p>
     <p>
     <label><span>行业类型：</span>
        <input type="text" id="industryName" readonly onclick="showHideDiv('window3');">
      </label>
      <label><span>工商注册号：</span>
        <input type="text" id="regNo">
      </label>
      <label><span>法定代表人：</span>
        <input type="text" id="legal">
      </label>
    </p>
    <p id="city_1">
		<label><span>省（市）：</span>
	<input type="text" onclick="showHideDiv('window1');" id="provinceName" readonly >
	</label>
		<label><span>城市（区）：</span>
		<input type="text" onclick="showCityList(); " id="cityName" readonly></label>
      <label><span>地址：</span>
        <input type="text" id="address">
      </label> 
	</p>
   
  
     <p>
     <label><span>开户银行：</span>
        <input type="text" id="openBank">
      </label>
      <label><span>银行账号：</span>
        <input type="text" id="bankAccount">
      </label>
       <label><span>开业时间：</span>
        <input type="text" id="openTime"  class="doubledate " readonly >
      </label>
	</p>
	
  
    <p>
     <label><span>经营范围：</span>
        <textarea id="major"></textarea>
      </label>
      <label><span>备注：</span>
        <textarea id="memo"></textarea>
      </label>   
    </p>
  <p>
     
      
       <label><span>状态：</span>
        <select id="status"><option value="1">正常</option><option value="0">停用</option></select>
      </label>
    </p>
   
    
    <div class="submit_btn">
      <input type="button" value="保存信息"  onclick="save();" class="common_btn" id="close_this">
      
    </div>
  </div>
  </div>
  <div class="fc"></div>
</div>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/header.js"></script>
<script type="text/javascript" src="../js/left.js"></script>
<script type="text/javascript" src="../js/footer.js"></script>
<script type="text/javascript">
clearThis("absoluteTxt");
showTab(2,5);
</script>
</body>
<!-- InstanceEnd --></html>
